package com.seguriapp.common.gwt.client;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.activity.shared.Activity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

import net.customware.gwt.dispatch.client.DispatchAsync;

public abstract class AbstractSeguriAppActivity extends AbstractActivity {

  protected static final long FIRST_PAGE = 1;

  protected DispatchAsync dispatchAsync;
  protected EventBus eventBus;
  protected PlaceController placeController;
  protected SeguriAppClientSession clientSession;
  protected AbstractSeguriAppPlace place;

  public AbstractSeguriAppActivity(final DispatchAsync dispatchAsync, final EventBus eventBus, final PlaceController placeController, final AbstractSeguriAppPlace place, final SeguriAppClientSession clientSession) {
    this.dispatchAsync = dispatchAsync;
    this.eventBus = eventBus;
    this.placeController = placeController;
    this.place = place;
    this.clientSession = clientSession;
  }

  public void start(final AcceptsOneWidget acceptsOneWidget, final EventBus eventBus) {
    onStart(acceptsOneWidget, eventBus);
  }

  /**
   * Metodo delegado del metodo
   * {@link Activity#start(AcceptsOneWidget, EventBus)} llamado si es que el
   * usuario tiene acceso.
   * 
   * @param acceptsOneWidget
   *          El widget que la actividad mostrara.
   * @param eventBus
   *          El bus de eventos del sistema.
   */
  protected abstract void onStart(final AcceptsOneWidget acceptsOneWidget, final EventBus eventBus);
}
